Skip to content

Redesign the resource details attributes and add a relationships tab - #1330

Merged
pfferrari merged 2 commits into
mainfrom
feat/773-new-resources
Nov 20, 2026
Merged

pfferrari merged 2 commits into
mainfrom
feat/773-new-resources

Conversation

@pfferrari

@pfferrari pfferrari commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Related to commercelayer/issues-app#773

What I did

The resource details (ResourceDetailsContent and useResourceDetailsModal) get a redesigned Attributes tab and an optional Relationships tab.

 <ResourceDetailsContent
   resource={order}
+  relationships={{
+    names: ["market", "line_items", "available_payment_methods"],
+    onSelect: ({ type, id }) => openDetails(type, id),
+  }}
 />
  • Tab row: ResourceDetailsContent takes three optional props for a container with no padding of its own, such as a column next to a list:

    • tabsSize: regular (default) or small, passed to Tabs (its small size is from Add a small size to Tabs #1332, and now has a 20px line, as designed);

    • edgeToEdge: the tab row runs from edge to edge, with the tabs and their content kept 24px from the sides. As in the design, the row is 52px tall with 16px above the tabs, and the content starts 12px under it, so the first line of every tab sits 24px under the row.

    • fillHeight: fills the height of the container; the tab row stays in place and only the open panel scrolls, so its scrollbar starts under the row.

    useResourceDetailsModal always uses all three, so the modal matches the details shown next to a list, and no longer accepts them.

  • Modal height and scroll: useResourceDetailsModal gives the modal a fixed height, clamp(480px, calc(70vh + 75px), 755px) (new height prop of Modal), and only the open panel scrolls inside it, under the tab row, which stays in place. Switching tabs, opening an event or expanding a relationship no longer resizes the modal. The gradient strips that hinted at the old inner scroll are gone; panelHeight still scrolls a panel on its own when set.

  • Modal: corners are rounded to 8px (rounded) instead of 16px (rounded-md). This applies to every modal. A new height prop fixes a modal's height (still capped by its min(90vh, 800px) maximum), and Modal.Body takes flush to drop its padding for content that lays out its own.

  • Events: the timeline matches the design: 14px day headings, 13px name and description, the time at 12px (the design has 11px, below our smallest text size), 72px rows, and a 2px black frame without shadow on the open event. This also applies to custom tabs built on ResourceDetailsTimeline.

  • Attributes: a single flat list, led by id and type, with a fixed label column and right-aligned values, in 12px monospace. The separate id/type card is gone. Object attributes keep their Json toggle.

  • Relationships: shown only when relationships is passed, right after Attributes. One row per relationship, sorted by name. Each row says whether the relationship holds a single record or many, told from its name (plural, or ending in skus).

    • A has-one sideloaded by the caller is read straight from the resource, with no request.
    • Any other relationship is fetched only when its row is expanded, ten records per page, with PaginationInfo and the total under the list. A row reopens on the page it was left on.
    • A relationship the SDK doesn't know shows an error instead of an empty list.
    • With onSelect, each related record is a button that hands back its type and id.
  • A11y: each row controls its panel, which is a section labelled by the row. The focus ring is drawn inside the rows and records, so the scrolling panel and the card don't clip it. Loading and errors are announced, and decorative icons are hidden.

  • PaginationInfo: the range and button labels are translated (common.pagination_range, common.previous_page, common.next_page). Its buttons use aria-disabled instead of disabled, so they keep keyboard focus while a page loads or on the last page. This applies to every paginated list, as do its buttons, now white so they no longer look disabled on a gray background. A top prop sets the room above the pager: 16px in a relationship, 24px (default) elsewhere.

  • Exports: ResourceRelationshipsConfig type.

  • Storybook: new WithRelationships story, with mocked relationship endpoints.

Screenshots

From the Storybook of this branch (Resources/useResourceDetailsModal → WithRelationships).

Attributes: small tabs on a row running from edge to edge of the modal, 8px corners; a single list led by ID and Type, labels in a fixed column, values right-aligned, empty values as a muted dash.

10-modal-attributes

Relationships: one row per relationship, telling a single relationship from a multiple one. Line items is expanded: fetched on expand, ten per page, with the total and the white pager 16px under the list.

11-modal-relationships

Events: day heading, rows and the open event as designed; the modal keeps the same height as on the other tabs.

12-modal-events

How to test

  • pnpm check, pnpm ts:check and pnpm test pass.
  • In Storybook, open Resources/useResourceDetailsModal → WithRelationships and click Open details:
    • The modal has 8px corners. The tabs are small, and their row runs from edge to edge of the modal, right under the header; the first line of each tab sits 24px under the row.
    • The modal keeps the same height on every tab, with an event open and with Line items expanded; only the open panel scrolls, with its scrollbar starting under the tab row and no fading strips.
    • In Events, opening an event frames it in black, with no shadow.
    • Attributes is a single list, starting with ID and Type.
    • Relationships lists four rows, three marked Has many and Market Has one.
    • Expand Market: the sideloaded market shows right away.
    • Expand Line items: ten records load, with 1-10 of 30 and the pager. › shows the next ten; collapsing and reopening the row keeps the page.
    • Click a record: the story's onSelect shows its type and id.
    • With the keyboard, tab through rows, records and pager: the focus ring is fully visible, and the pager keeps focus while turning pages.

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests).
  • Make sure to add/update documentation regarding your changes.
  • You are NOT deprecating/removing a feature.

@netlify

netlify Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for commercelayer-app-elements ready!

Name Link
🔨 Latest commit 08ed419
🔍 Latest deploy log https://app.netlify.com/projects/commercelayer-app-elements/deploys/6aff34f3989f3de181e36818
😎 Deploy Preview https://deploy-preview-1330--commercelayer-app-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/commercelayer/app-elements/@commercelayer/app-elements@08ed419

commit: 08ed419

…s tab

The Attributes tab is a single flat list, led by id and type, with a fixed
label column and right-aligned values.

`relationships: { names, onSelect }` adds a Relationships tab: one row per
relationship, telling a single relationship from a multiple one by its name.
Sideloaded has-one relationships are read from the resource; any other is
fetched when its row is expanded, ten records per page. `onSelect` makes each
related record clickable, e.g. to open it in another details modal.

PaginationInfo is translated and uses `aria-disabled`, so its buttons keep
keyboard focus while a page loads.
@pfferrari
pfferrari force-pushed the feat/773-new-resources branch from 06820ab to 4343e1e Compare November 19, 2026 14:17
@pfferrari pfferrari self-assigned this Nov 19, 2026
@pfferrari pfferrari added the enhancement New feature or request label Nov 19, 2026
@pfferrari
pfferrari force-pushed the feat/773-new-resources branch 6 times, most recently from 987b47b to 7499fd6 Compare November 19, 2026 17:33
@pfferrari
pfferrari force-pushed the feat/773-new-resources branch from 7499fd6 to 08ed419 Compare November 19, 2026 17:42
@pfferrari
pfferrari merged commit 98924ae into main Nov 20, 2026
11 checks passed
@pfferrari
pfferrari deleted the feat/773-new-resources branch November 20, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants